
package com.jf.cloud.service.sysmanager.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jf.cloud.service.sysmanager.common.base.BaseService;
import com.jf.cloud.service.sysmanager.common.base.GenericsUtils;
import com.jf.cloud.service.sysmanager.common.db.BaseDao;
import com.jf.cloud.service.sysmanager.common.db.Condition;
import com.jf.cloud.service.sysmanager.dao.IPubgPhoneMsgService;
import com.jf.cloud.service.sysmanager.entity.PubgPhoneMsg;


/**
 * 员工服务实现
 * 
 * @author 绝峰代码机1.0 创建时间：2018-03-31
 */
@Service("pubgPhoneMsgService")
public class PubgPhoneMsgServiceImpl extends BaseService<PubgPhoneMsg, Long> implements IPubgPhoneMsgService {

	/**
	 * 日志
	 */
	private static Log log = LogFactory.getLog(PubgPhoneMsgServiceImpl.class);

	/**
	 * JPA公共DAO
	 */
	@Resource
	private BaseDao baseDao;

	private RowMapper<PubgPhoneMsg> rowMapper = new BeanPropertyRowMapper<PubgPhoneMsg>(GenericsUtils.getSuperClassGenricType(this.getClass()));

	/**
	 * 根据主键查询员工
	 * 
	 * @author 绝峰代码机1.0 创建时间：2018-03-31
	 */
	public PubgPhoneMsg findPubgPhoneMsg(Long rowId) throws Exception {
		try {
			return this.baseDao.findObject("", rowMapper, rowId);
		} catch (Exception e) {
			throw new Exception("根据主键查询员工出错！", e);
		}
	}

	/**
	 * 根据查询条件获取员工列表
	 * 
	 * @author 绝峰代码机1.0 创建时间：2018-03-31
	 */
	public List<PubgPhoneMsg> findPubgPhoneMsgList(Condition qc) throws Exception {
		try {
			return this.baseDao.findList("", rowMapper);
		} catch (Exception e) {
			throw new Exception("根据查询条件获取员工列表出错！", e);
		}
	}

	/**
	 * 新增/修改员工
	 * 
	 * @author 绝峰代码机1.0 创建时间：2018-03-31
	 */
	@Transactional
	public PubgPhoneMsg saveOrUpdatePubgPhoneMsg(PubgPhoneMsg pubgPhoneMsg) throws Exception {
		try {
			return this.baseDao.saveAll(pubgPhoneMsg);
		} catch (Exception e) {
			throw new Exception("新增/修改员工出错！", e);
		}
	}

}
